//
//  GPChatController+Message.h
//  GuaPi
//
//  Created by 陈华 on 2017/6/22.
//  Copyright © 2017年 Joanlove. All rights reserved.
//

#import "GPChatController.h"
@class GPMessageItem;

@interface GPChatController (Message) <EMChatManagerDelegate>

#pragma mark - 消息接收-EMChatManagerDelegate
/*!
 @method
 @brief 接收到一条及以上非cmd消息
 */
- (void)messagesDidReceive:(NSArray *)aMessages;


#pragma mark - 消息相关的工具方法
/**
 向数据源中追加消息（判断是否显示时间）
 
 @param messages 数据源
 @param messageItem 消息对象
 */
- (void)messageArray:(NSMutableArray *)messages addMessage:(GPMessageItem *)messageItem;


/**
 根据环信id 从本地加载头像信息  并完善消息的头像和昵称

 @param message 环信的消息
 @return 已经完善的消息模型
 */
- (GPMessageItem *)gp_setupMessageUserInfo:(EMMessage *)message;


#pragma mark - 消息发送

/**
 发送文本消息
 
 @param text 文本内容
 @param to 接收者
 @param conversationId 会话ID
 @param chatType 聊天类型
 @param progress 进度
 @param completion 完成后的回调
 @return UI显示的messageItem
 */
- (GPMessageItem *)sendTextMessage:(NSString *)text
                                to:(NSString *)to
                    conversationId:(NSString *)conversationId
                          chatType:(EMChatType)chatType
                          progress:(void(^)(int progress))progress
                        completion:(void(^)(GPMessageItem *messageItem, EMMessage *message, EMError *error))completion;


/**
 发送图片消息

 @param originImage 原始大图
 @param thumbnail 小图 -- 目前废弃
 @param to 接受者
 @param conversationId 会话id
 @param chatType 聊天类型
 @param progress 进度
 @param completion 完成后的糊掉
 @return UI显示的messageItem
 */
- (GPMessageItem *)sendImageMessage:(UIImage *)originImage thumbnailImage:(UIImage *)thumbnail to:(NSString *)to conversationId:(NSString *)conversationId chatType:(EMChatType)chatType progress:(void(^)(int progress))progress completion:(void(^)(GPMessageItem *messageItem ,EMMessage *message, EMError *error))completion;


/**
 发送语音消息

 @param audioPath 语音文件的地址
 @param fileName 语音文件名
 @param duration 语音时长
 @param conversationId 会话id
 @param to 接受者
 @param chatType 聊天类型
 @param progress 进度
 @param completion 回调
 @return UI显示的messageItem
 */
- (GPMessageItem *)sendVoiceMessage:(NSString *)audioPath displayName:(NSString *)fileName duration:(int)duration conversationId:(NSString *)conversationId to:(NSString *)to chatType:(EMChatType)chatType progress:(void(^)(int progress))progress completion:(void(^)(GPMessageItem *messageItem ,EMMessage *message, EMError *error))completion;


/**
 发送地址消息

 @param latitude 经纬度
 @param longitude 经纬度
 @param address 地址
 @param name    地名
 @param to 接受者
 @param conversationId 会话id
 @param chatType 聊天类型
 @param progress 进度
 @param completion 完成后的回调
 @return UI显示的messageitem
 */
- (GPMessageItem *)sendLocationMessageLatitude:(double)latitude longitude:(double)longitude address:(NSString *)address name:(NSString *)name to:(NSString *)to conversationId:(NSString *)conversationId chatType:(EMChatType)chatType progress:(void(^)(int progress))progress completion:(void(^)(GPMessageItem *messageItem ,EMMessage *message, EMError *error))completion;



/**
 发送SOS紧急消息

 @param originImage 图片
 @param latitude 经纬度
 @param longitude 经纬度
 @param address 地址
 @param to 接受者
 @param conversationId 会话id
 @param chatType 聊天类型
 @param progress 进度
 @param completion 完成后的回到
 @return UI显示的messageItem
 */
- (GPMessageItem *)sendSOSMessage:(UIImage *)originImage latitude:(double)latitude longitude:(double)longitude address:(NSString *)address to:(NSString *)to conversationId:(NSString *)conversationId chatType:(EMChatType)chatType progress:(void(^)(int progress))progress completion:(void(^)(GPMessageItem *messageItem ,EMMessage *message, EMError *error))completion;

@end
